<?php


$dbc = mysql_connect('localhost', 'dbuser3', 'welcome1');
mysql_select_db('db3', $dbc);

$tmp    = mysql_query("SET NAMES utf8");
$places = mysql_query("SELECT * FROM fmap_mplace");
$nrows  = mysql_num_rows($places);
$outxml = '<?xml version="1.0" standalone="yes"?><RECORDS>';
for ($i = 0; $i < $nrows; $i++)
{
  $row     = mysql_fetch_array($places, MYSQL_ASSOC);
  $nid     = isset($row['nid'])     && !empty($row['nid'])     ? $row['nid']     : "\"\"";
  $cname   = isset($row['cname'])   && !empty($row['cname'])   ? $row['cname']   : "\"\"";
  $ename   = isset($row['ename'])   && !empty($row['ename'])   ? $row['ename']   : "\"\"";
  $street  = isset($row['street'])  && !empty($row['street'])  ? $row['street']  : "\"\"";
  $suite   = isset($row['suite'])   && !empty($row['suite'])   ? $row['suite']   : "\"\"";
  $city    = isset($row['city'])    && !empty($row['city'])    ? $row['city']    : "\"\"";
  $state   = isset($row['state'])   && !empty($row['state'])   ? $row['state']   : "\"\"";
  $zip     = isset($row['zip'])     && !empty($row['zip'])     ? $row['zip']     : "\"\"";
  $county  = isset($row['county'])  && !empty($row['county'])  ? $row['county']  : "\"\"";
  $country = isset($row['country']) && !empty($row['country']) ? $row['country'] : "\"\"";
  $lat     = isset($row['lat'])     && !empty($row['lat'])     ? $row['lat']     : "\"\"";
  $lng     = isset($row['lng'])     && !empty($row['lng'])     ? $row['lng']     : "\"\"";
  $elv     = isset($row['elv'])     && !empty($row['elv'])     ? $row['elv']     : "\"\"";
  $phone   = isset($row['phone'])   && !empty($row['phone'])   ? $row['phone']  : "\"\"";
  $fax     = isset($row['fax'])     && !empty($row['fax'])     ? $row['fax']     : "\"\"";
  $web     = isset($row['web'])     && !empty($row['web'])     ? $row['web']     : "\"\"";

  $outxml .= "<RECORD>"  .
             "<nid>"     . $nid     . "</nid>"     .
             "<cname>"   . $cname   . "</cname>"   .
             "<ename>"   . $ename   . "</ename>"   .
             "<street>"  . $street  . "</street>"  .
             "<suite>"   . $suite   . "</suite>"   .
             "<city>"    . $city    . "</city>"    .
             "<state>"   . $state   . "</state>"   .
             "<zip>"     . $zip     . "</zip>"     .
             "<county>"  . $county  . "</county>"  .
             "<country>" . $country . "</country>" .
             "<lat>"     . $lat     . "</lat>"     .
             "<lng>"     . $lng     . "</lng>"     .
             "<elv>"     . $elv     . "</elv>"     .
             "<phone>"   . $phone   . "</phone>"  .
             "<fax>"     . $fax     . "</fax>"     .
             "<web>"     . $web     . "</web>"     .
             "</RECORD>";
}
$outxml .= "</RECORDS>";

mysql_free_result($places);
mysql_close($dbc);

header("Cache-Control: no-store, no-cache, must-revalidate");
header("Content-Type: text/xml; charset=UTF-8");
echo $outxml;


?>
